Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EuiBottomBar: allow customization of whether the component makes room for itself #3641

Conversation

dannya
Copy link
Contributor

@dannya dannya commented Jun 23, 2020

  • Add new affordForDisplacement prop (default: true) to allow customization of whether the component makes room for itself by adding padding equivalent to its own height on the document body element.

Use case is a web app which ordinarily doesn't require vertical scrollbars (with a large enough browser viewport) - the existing unconfigurable behavior was forcing a vertical scrollbar to appear in this scenario, as can be seen in the updated component doc page.

  • Make clear that the paddingSize prop default is "m".

Summary

The most relevant previous code change this builds off is #680 by @snide

I understand that there is the facility to specify a custom className to effect this, but my rationale here is two-fold - it feels inelegant to have to set a custom CSS class with an !important rule in order to override the existing behavior (as it is achieved with inline styles), and IMO it is worthwhile having an explicit ability to opt-out of this behavior (whilst keeping the existing behavior as the default).

I've seen (quite late into making this change) that there is a similar EuiControlBar component which seems to be favored for future development effort - the same mechanism for automatically adding a height displacement occurs there too. If you are satisfied with my changes here, I will make the same component prop addition in that component, and then update the CHANGELOG.

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in IE11 and Firefox
  • Props have proper autodocs
  • Added documentation
  • Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

* Add new `affordForDisplacement` prop (default: true) to allow customization of whether the component makes room for itself by adding padding equivalent to its own height on the document body element.

Use case a web app which ordinarily doesn't require vertical scrollbars (with a large enough browser viewport) - the existing unconfigurable behavior was forcing a vertical scrollbar to appear in this scenario, as can be seen in the updated component doc page.

* Make clear that the `paddingSize` prop default is "m".
@kibanamachine
Copy link

Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually?

@snide
Copy link
Contributor

snide commented Jun 23, 2020

jenkins test this

@cchaos
Copy link
Contributor

cchaos commented Jun 23, 2020

Chromium failed. Jenkins test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_3641/

@cchaos
Copy link
Contributor

cchaos commented Jun 23, 2020

The original reason for adding the padding the the body element is to prevent the overlap of content when the bar exists, for example this scenario:
Screen Shot 2020-06-23 at 16 08 52 PM

We will then need to provide the consumer an easy way to afford for this in the correct place. We've typically done this through SASS mixins, but since EuiBottomBar can accept any children, it can just about be any size. Therefore, we will need to allow passing/forwarding a ref to the component so consumers can do their own sizing.

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling this one. Let's not add this to EuiControlBar just yet. We've been implementing some similar behaviors with fixed EuiHeader's and would rather rely on SASS mixins when we can.

src-docs/src/views/bottom_bar/bottom_bar_example.js Outdated Show resolved Hide resolved
src-docs/src/views/bottom_bar/bottom_bar_example.js Outdated Show resolved Hide resolved
src/components/bottom_bar/bottom_bar.tsx Outdated Show resolved Hide resolved
* Whether the component should apply padding on the document body element to afford for its own displacement height.
* Default is true.
*/
affordForDisplacement: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test for this prop?

dannya and others added 3 commits June 26, 2020 21:47
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@cchaos
Copy link
Contributor

cchaos commented Aug 18, 2020

Hey @dannya , Just wondering if you were still going to wrap up this PR or if you need help getting it over the line? I think all it really needs are some tests.

@dannya
Copy link
Contributor Author

dannya commented Aug 21, 2020

Hi @cchaos , I did start on the tests for this, but wasn't sure of the best approach for testing this specific new functionality (because it would need to test an effect external to the component, in this case the document.body.style.paddingBottom value) - and since then I've been snowed under with work.

My understanding is that typical Jest tests and snapshots are only testing the rendered component HTML, rather than in the context of a full HTML page (with body, etc elements).

Any ideas on a way of testing this specific case?

Thanks,
Danny

@cchaos
Copy link
Contributor

cchaos commented Aug 21, 2020

Yes, that is ok for now (testing simply the component render). Mainly we want to ensure that the component doesn't error out when using the prop appropriately. We can always circle back to testing of the actual behavior, but for now the simple snapshot is fine.

@cchaos
Copy link
Contributor

cchaos commented Oct 19, 2020

Hi @dannya I was finishing up this PR for you and attempted to push my changes directly but permissions were denied so I've created a new PR based off this one and going to close this one directly.

@cchaos cchaos closed this Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants